** USE RESULT TO ASSESS DIFFERENCES IN SURVIVAL CURVES FOR ALL VARIABLES
** LAST ALTERED 08/08/2019

set scheme s2mono
use "/DATA Dataverse.dta", clear

********************************************************************************
**** Variables *******************************************************************
********************************************************************************
/*
Main1 =>  Narrow Delegation
Deadline2 => Deadline 
HeinsScholarCheck => Significance
PagesinEnactedBill => Statute Complexity    
PreHearings =>  Hearings Ex Ante
ACCmust => Workload Accumulation  
IMDOI_DC_Emply => DOI Employees 
DOI_nprms_yearly => DOI NPRMs   
Hearings => Hearings Ex Post  
SenLead  => Senate Lead 
HouseLead =>  House Lead
UnifiedPass => Unified Government  
InitialPres => Initial Administration
InitialCong => Partisan Coaltion 
TimetoFirstPElec  => Time to Presidential Election			
*/			
				
 
********************************************************************************
**** Table 1 *******************************************************************
********************************************************************************

sum 			Main1 Deadline2  HeinsScholarCheck  ///
				PagesinEnactedBill    PreHearings   ///
				ACCmust  IMDOI_DC_Emply  DOI_nprms_yearly  ///
				Hearings  SenLead  HouseLead  ///
				UnifiedPass  InitialPres  InitialCong  TimetoFirstPElec  
				
stjoin

********************************************************************************
**** Table 2 *******************************************************************
********************************************************************************
		
********************************************************************************
** Full Models
********************************************************************************

** 1 **
stpm2 	 		Main1 i.Deadline2 HeinsScholarCheck  ///
				PagesinEnactedBill  PreHearings ///
				ACCmust IMDOI_DC_Emply	DOI_nprms_yearly  ///
				Hearings  i.SenLead i.HouseLead ///
				i.UnifiedPass TimetoFirstPElec i.InitialPres##i.InitialCong , scale(o) df(3)  difficult 
				di " AIC = " %7.2f e(AIC) " BIC = " %7.2f e(BIC)
				
estimates store B1	
outreg2 using NewTable.doc, stats(coef pval)

** 2 **
stpm2 	 		Main1 i.Deadline2 HeinsScholarCheck  ///
				PagesinEnactedBill PreHearings ///
				ACCmust IMDOI_DC_Emply	DOI_nprms_yearly  ///
				Hearings  i.SenLead i.HouseLead ///
				i.UnifiedPass TimetoFirstPElec i.InitialPres##i.InitialCong  if Main1==1, scale(h) df(3)  difficult
				di " AIC = " %7.2f e(AIC) " BIC = " %7.2f e(BIC)
				
estimates store B2	
outreg2 using NewTable.doc, stats(coef pval)

** 3 ** 
stpm2 	 		Main1 i.Deadline2 HeinsScholarCheck  ///
				PagesinEnactedBill  PreHearings ///
				ACCmust IMDOI_DC_Emply	DOI_nprms_yearly  ///
				Hearings  i.SenLead i.HouseLead ///
				i.UnifiedPass TimetoFirstPElec i.InitialPres##i.InitialCong if Main1==0, scale(o) df(3)  difficult 	
				di " AIC = " %7.2f e(AIC) " BIC = " %7.2f e(BIC)
				
estimates store B3			
outreg2 using NewTable.doc, stats(coef pval)

********************************************************************************
** Figure 1
********************************************************************************
set scheme s2mono

estimates restore B1

sts graph , by(Main1) tmax(1825) title("") xlabel(0(365)1825) xline(365, lwidth(vthin) lcolor(black) lpattern(dash)) xline(730, lwidth(vthin) lcolor(black) lpattern(dash)) ///
	xline(1095, lwidth(thin) lcolor(black) lpattern(dash)) xline(1460, lwidth(thin) lcolor(black) lpattern(dash)) 
	
********************************************************************************
** Figure 2
********************************************************************************
estimates restore B1
** Survival Curves
		
global 	mean		Main1 0 Deadline2 0 HeinsScholarCheck 10 ///
					PagesinEnactedBill 17 PreHearings 4  ///
					ACCmust 12 IMDOI_DC_Emply 7525 DOI_nprms_yearly 89 ///
					Hearings 22 SenLead 0 HouseLead 0 ///
					UnifiedPass 1 InitialPres 0 InitialCong 0 TimetoFirstPElec 643
					
global 	meanmust	Main1 1 Deadline2 0 HeinsScholarCheck 10 ///
					PagesinEnactedBill 17 PreHearings 4  ///
					ACCmust 12 IMDOI_DC_Emply 7525 DOI_nprms_yearly 89 ///
					Hearings 22 SenLead 0 HouseLead 0 ///
					UnifiedPass 1 InitialPres 0 InitialCong 0 TimetoFirstPElec 643		
					
predict s1, survival at($mean) ci
predict s1b, survival at($meanmust) ci

label variable s1 "Broad Delegation"
label variable s1b "Narrow Delegation"

preserve
gen tt = round(_t, 0.05)
quietly bysort tt : drop if _n > 1
global stuff xtitle("Days") ytitle("Difference in Survival Curves") sort  ///
	lpattern(l dash) lwidth(thick thick thick) ylabel(, angle(h) ) ///
	xlabel(0(365)1825) xline(365, lwidth(vthin) lpattern(dash)) yline(0)  xline(730, lwidth(vthin) lpattern(dash)) ///
	xline(1095, lwidth(thin) lpattern(dash)) xline(1460, lwidth(thin) lpattern(dash))
drop if tt>1825
line s1 s1b tt, $stuff title("") caption("") legend(cols(1))  name(g1, replace) 
restore
					

** Difference in Survival Curves
global 	variables		Deadline2 0 HeinsScholarCheck 10 ///
						PagesinEnactedBill 17  PreHearings 4  ///
						ACCmust 12 IMDOI_DC_Emply 7525 DOI_nprms_yearly 89 ///
						Hearings 22 SenLead 0 HouseLead 0 ///
						UnifiedPass 1 InitialPres 0 InitialCong 0 TimetoFirstPElec 643
predict ss1, sdiff1(Main1 0  $variables ) sdiff2(Main1 1  $variables) ci level(90)

preserve
gen tt = round(_t, 0.05)
quietly bysort tt : drop if _n > 1

drop if tt>1825	
line ss1  ss1_lci ss1_uci tt, xtitle("Days") ytitle("Difference in Survival Curves") sort legend(off) ///
	lpattern(l dash dash) lwidth(thick thin thin) ylabel(, angle(h) ) lcolor(black black black) ///
	xlabel(0(365)1825) xline(365, lwidth(vthin) lcolor(black) lpattern(dash)) xline(730, lwidth(vthin) lcolor(black) lpattern(dash)) ///
	xline(1095, lwidth(thin) lcolor(black) lpattern(dash)) xline(1460, lwidth(thin) lcolor(black) lpattern(dash)) ///
	title("") caption("") 
	
restore

drop s1 s1_lci s1_uci s1b s1b_lci s1b_uci ss1 ss1_lci ss1_uci

********************************************************************************
** Figure 3
********************************************************************************
estimates restore B2
	
** Mean	
global 	mean		Deadline2 0 HeinsScholarCheck 10 ///
					PagesinEnactedBill 21  PreHearings 6  ///
					ACCmust 14 IMDOI_DC_Emply 7685 DOI_nprms_yearly 90 ///
					Hearings 20 SenLead 0 HouseLead 0 ///
					UnifiedPass 1 InitialPres 0 InitialCong 0 TimetoFirstPElec 514
						

** Ex Ante Faster					
global 	exanteA		Deadline2 1 PreHearings 18 PagesinEnactedBill 130   ///
					UnifiedPass 1   ///
					Hearings 20 InitialPres 0 InitialCong 0 SenLead 0 HouseLead 0 ///
					ACCmust 14 IMDOI_DC_Emply 7685 DOI_nprms_yearly 90 ///
					TimetoFirstPElec 514  HeinsScholarCheck 10
** Expost Faster					
global 	expostA		Deadline2 0 HeinsScholarCheck 10 ///
					PagesinEnactedBill 21  PreHearings 6  ///
					ACCmust 14 IMDOI_DC_Emply 7685 DOI_nprms_yearly 90 ///
					UnifiedPass 1  TimetoFirstPElec 514 ///	
					Hearings 1 SenLead 0 HouseLead 1 InitialPres 0 InitialCong 0	
					
** Ex Ante Faster & Expost Faster								
global 	exanteexpostA		Deadline2 1 PreHearings 18 PagesinEnactedBill 130   ///
					UnifiedPass 1   ///
					Hearings 1 InitialPres 0 InitialCong 0 SenLead 0 HouseLead 1 ///
					ACCmust 14 IMDOI_DC_Emply 7685 DOI_nprms_yearly 90 ///
					TimetoFirstPElec 514  HeinsScholarCheck 10
									
	
** Mean vs 
predict ss1, sdiff1($mean) sdiff2($exanteA) ci level(90)
predict ss2, sdiff1($mean) sdiff2($expostA) ci level(90)
predict ss3, sdiff1($mean) sdiff2($exanteexpostA) ci level(90)

label variable ss1 "Mean/Mode vs. Congress ex ante fast"
label variable ss2 "Mean/Mode vs. Congress ex post fast"
label variable ss3 "Mean/Mode vs. Congress ex ante & ex post fast"

preserve
gen tt = round(_t, 0.05)
quietly bysort tt : drop if _n > 1
global stuff xtitle("Days") ytitle("Difference in Survival Curves") sort  ///
	lpattern(l dash dot) lwidth(thick thick thick) ylabel(, angle(h) ) ///
	xlabel(0(365)1825) xline(365, lwidth(vthin) lpattern(dash)) yline(0)  xline(730, lwidth(vthin) lpattern(dash)) ///
	xline(1095, lwidth(thin) lpattern(dash)) xline(1460, lwidth(thin) lpattern(dash))
drop if tt>1825
line ss1 ss2 ss3 tt, $stuff title("") caption("") legend(cols(1))  name(g1, replace) 
restore
	
** Not presented: Statistical Differences	
** Mean vs expostA
preserve
predict ss, sdiff1($mean) sdiff2($expostA) ci level(90)
gen tt = round(_t, 0.05)
quietly bysort tt : drop if _n > 1
global stuff xtitle("Days") ytitle("Difference in Survival Curves") sort legend(off) ///
	lpattern(l - - ) lwidth(thick ) ylabel(, angle(h) ) ///
	xlabel(0(365)1825) xline(365, lwidth(vthin) lpattern(dash)) yline(0)  xline(730, lwidth(vthin) lpattern(dash)) ///
	xline(1095, lwidth(thin) lpattern(dash)) xline(1460, lwidth(thin) lpattern(dash))
drop if tt>1825
line ss ss_*  tt, $stuff title("") caption("$DATE")   name(g1, replace) 
restore

** mean vs exanteA
preserve
predict ss, sdiff1($mean) sdiff2($exanteA) ci level(90)
gen tt = round(_t, 0.05)
quietly bysort tt : drop if _n > 1
global stuff xtitle("Days") ytitle("Difference in Survival Curves") sort legend(off) ///
	lpattern(l - - ) lwidth(thick ) ylabel(, angle(h) ) ///
	xlabel(0(365)1825) xline(365, lwidth(vthin) lpattern(dash)) yline(0)  xline(730, lwidth(vthin) lpattern(dash)) ///
	xline(1095, lwidth(thin) lpattern(dash)) xline(1460, lwidth(thin) lpattern(dash))
drop if tt>1825
line ss ss_*  tt, $stuff title("") caption("$DATE")   name(g1, replace) 
restore


** mean vs exanteexpostA
preserve
predict ss, sdiff1($mean) sdiff2($exanteexpostA) ci level(90)
gen tt = round(_t, 0.05)
quietly bysort tt : drop if _n > 1
global stuff xtitle("Days") ytitle("Difference in Survival Curves") sort legend(off) ///
	lpattern(l - - ) lwidth(thick ) ylabel(, angle(h) ) ///
	xlabel(0(365)1825) xline(365, lwidth(vthin) lpattern(dash)) yline(0)  xline(730, lwidth(vthin) lpattern(dash)) ///
	xline(1095, lwidth(thin) lpattern(dash)) xline(1460, lwidth(thin) lpattern(dash))
drop if tt>1825
line ss ss_*  tt, $stuff title("") caption("$DATE")   name(g1, replace) 
restore
	
drop ss1 ss1_lci ss1_uci ss2 ss2_lci ss2_uci ss3 ss3_lci ss3_uci	


********************************************************************************
** Figure 4
********************************************************************************
estimates restore B3
	
** Mean/Mode
global 	mean		Main1 0 Deadline2 0 HeinsScholarCheck 10 ///
					PagesinEnactedBill 17  PreHearings 4  ///
					ACCmust 12 IMDOI_DC_Emply 7512 DOI_nprms_yearly 88 ///
					Hearings 22 SenLead 0 HouseLead 0 ///
					UnifiedPass 1 InitialPres 0 InitialCong 0 TimetoFirstPElec 654
						

** Departmental Faster					
global 	deptA		 Deadline2 0 HeinsScholarCheck 10 ///
					PagesinEnactedBill 17 PreHearings 4  ///
					ACCmust 3 IMDOI_DC_Emply 5278 DOI_nprms_yearly 135 ///
					Hearings 22 SenLead 0 HouseLead 0 ///
					UnifiedPass 1 InitialPres 0 InitialCong 0 TimetoFirstPElec 654
					
** Departmental Slower					
global 	deptB		Main1 0 Deadline2 0 HeinsScholarCheck 10 ///
					PagesinEnactedBill 17  PreHearings 4  ///
					ACCmust 21 IMDOI_DC_Emply 8881 DOI_nprms_yearly 37 ///
					Hearings 22 SenLead 0 HouseLead 0 ///
					UnifiedPass 1 InitialPres 0 InitialCong 0 TimetoFirstPElec 654
						
	
	
predict ssY1, sdiff1($mean) sdiff2($deptA) ci level(90)
predict ssY2, sdiff1($mean) sdiff2($deptB) ci level(90)
					
label variable ssY1 "Mean/Mode vs. Department fast"
label variable ssY2 "Mean/Mode vs. Department slow"
					
** Differences in Survival Curves
preserve
gen tt = round(_t, 0.05)
quietly bysort tt : drop if _n > 1
global stuff xtitle("Days") ytitle("Difference in Survival Curves") sort  ///
	lpattern(l dash l) lwidth(thick thick thick) ylabel(, angle(h) ) ///
	xlabel(0(365)1825) xline(365, lwidth(vthin) lpattern(dash)) yline(0)  xline(730, lwidth(vthin) lpattern(dash)) ///
	xline(1095, lwidth(thin) lpattern(dash)) xline(1460, lwidth(thin) lpattern(dash) )
drop if tt>1825
line ssY1 ssY2 tt, $stuff title("") caption("$DATE") legend(cols(1))  name(g1, replace) 
restore
		
	
** Not presented: Statistical Differences		
** Mean vs deptA
preserve
predict ss, sdiff1($mean) sdiff2($deptA) ci level(90)
gen tt = round(_t, 0.05)
quietly bysort tt : drop if _n > 1
global stuff xtitle("Days") ytitle("Difference in Survival Curves") sort legend(off) ///
	lpattern(l - - ) lwidth(thick ) ylabel(, angle(h) ) ///
	xlabel(0(365)1825) xline(365, lwidth(vthin) lpattern(dash)) yline(0)  xline(730, lwidth(vthin) lpattern(dash)) ///
	xline(1095, lwidth(thin) lpattern(dash)) xline(1460, lwidth(thin) lpattern(dash))
drop if tt>1825
line ss ss_* tt, $stuff title("") caption("$DATE")   name(g1, replace) 

graph export "_T3 ALL SCEN Mean vs Dept Fast.pdf", as(pdf) replace
restore


** Mean vs deptB
preserve
predict ss, sdiff1($mean) sdiff2($deptB) ci level(90)
gen tt = round(_t, 0.05)
quietly bysort tt : drop if _n > 1
global stuff xtitle("Days") ytitle("Difference in Survival Curves") sort legend(off) ///
	lpattern(l - - ) lwidth(thick ) ylabel(, angle(h) ) ///
	xlabel(0(365)1825) xline(365, lwidth(vthin) lpattern(dash)) yline(0)  xline(730, lwidth(vthin) lpattern(dash)) ///
	xline(1095, lwidth(thin) lpattern(dash)) xline(1460, lwidth(thin) lpattern(dash))
drop if tt>1825
line ss ss_* tt, $stuff title("") caption("$DATE")   name(g1, replace) 

graph export "_T3 ALL SCEN Mean vs Dept Slow.pdf", as(pdf) replace
restore

drop ssY1 ssY1_lci ssY1_uci ssY2 ssY2_lci ssY2_uci

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
